# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# If you are running on SunOS 5.x machines, uncomment the next line
GCCDIR = /auto/home-scf-22/csci402/testgnu/decstation-ultrix/bin/
LDFLAGS = -T newscript -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)

# if you aren't cross-compiling:
# GCCDIR =
# LDFLAGS = -N -T 0
# ASFLAGS =
# CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld
CPP = $(GCCDIR)cpp

INCDIR =-I../userprog -I../threads
CFLAGS = -G 0 -c $(INCDIR)

all: halt matmult sort testfiles forkAndLockTest execTest lockAndCVTest networkBroadcastTest networkWaitTest networkSignalTest networkLockTest superMarketSim twoSuperMarketSims superMarketTest1 superMarketTest2 superMarketTest3 superMarketTest4 superMarketTest5 superMarketTest6 superMarketTest7 superMarketTest8 superMarketTest9 superMarketTest10

start.o: start.s ../userprog/syscall.h
	$(CPP) $(CPPFLAGS) start.s > strt.s
	$(AS) $(ASFLAGS) -o start.o strt.s
	rm strt.s

halt.o: halt.c
	$(CC) $(CFLAGS) -c halt.c
halt: halt.o start.o
	$(LD) $(LDFLAGS) start.o halt.o -o halt.coff
	../bin/coff2noff halt.coff halt

sort.o: sort.c
	$(CC) $(CFLAGS) -c sort.c
sort: sort.o start.o
	$(LD) $(LDFLAGS) start.o sort.o -o sort.coff
	../bin/coff2noff sort.coff sort

matmult.o: matmult.c
	$(CC) $(CFLAGS) -c matmult.c
matmult: matmult.o start.o
	$(LD) $(LDFLAGS) start.o matmult.o -o matmult.coff
	../bin/coff2noff matmult.coff matmult

testfiles.o: testfiles.c
	$(CC) $(CFLAGS) -c testfiles.c
testfiles: testfiles.o start.o
	$(LD) $(LDFLAGS) start.o testfiles.o -o testfiles.coff
	../bin/coff2noff testfiles.coff testfiles
	
forkAndLockTest.o: forkAndLockTest.c
	$(CC) $(CFLAGS) -c forkAndLockTest.c
forkAndLockTest: forkAndLockTest.o start.o
	$(LD) $(LDFLAGS) start.o forkAndLockTest.o -o forkAndLockTest.coff
	../bin/coff2noff forkAndLockTest.coff forkAndLockTest
	
execTest.o: execTest.c
	$(CC) $(CFLAGS) -c execTest.c
execTest: execTest.o start.o
	$(LD) $(LDFLAGS) start.o execTest.o -o execTest.coff
	../bin/coff2noff execTest.coff execTest
	
lockAndCVTest.o: lockAndCVTest.c
	$(CC) $(CFLAGS) -c lockAndCVTest.c
lockAndCVTest: lockAndCVTest.o start.o
	$(LD) $(LDFLAGS) start.o lockAndCVTest.o -o lockAndCVTest.coff
	../bin/coff2noff lockAndCVTest.coff lockAndCVTest

superMarketSim.o: superMarketSim.c
	$(CC) $(CFLAGS) -c superMarketSim.c
superMarketSim: superMarketSim.o start.o
	$(LD) $(LDFLAGS) start.o superMarketSim.o -o superMarketSim.coff
	../bin/coff2noff superMarketSim.coff superMarketSim

twoSuperMarketSims.o: twoSuperMarketSims.c
	$(CC) $(CFLAGS) -c twoSuperMarketSims.c
twoSuperMarketSims: twoSuperMarketSims.o start.o
	$(LD) $(LDFLAGS) start.o twoSuperMarketSims.o -o twoSuperMarketSims.coff
	../bin/coff2noff twoSuperMarketSims.coff twoSuperMarketSims

superMarketTest1.o: superMarketTest1.c
	$(CC) $(CFLAGS) -c superMarketTest1.c
superMarketTest1: superMarketTest1.o start.o
	$(LD) $(LDFLAGS) start.o superMarketTest1.o -o superMarketTest1.coff
	../bin/coff2noff superMarketTest1.coff superMarketTest1

superMarketTest2.o: superMarketTest2.c
	$(CC) $(CFLAGS) -c superMarketTest2.c
superMarketTest2: superMarketTest2.o start.o
	$(LD) $(LDFLAGS) start.o superMarketTest2.o -o superMarketTest2.coff
	../bin/coff2noff superMarketTest2.coff superMarketTest2	

superMarketTest3.o: superMarketTest3.c
	$(CC) $(CFLAGS) -c superMarketTest3.c
superMarketTest3: superMarketTest3.o start.o
	$(LD) $(LDFLAGS) start.o superMarketTest3.o -o superMarketTest3.coff
	../bin/coff2noff superMarketTest3.coff superMarketTest3	
	
superMarketTest4.o: superMarketTest4.c
	$(CC) $(CFLAGS) -c superMarketTest4.c
superMarketTest4: superMarketTest4.o start.o
	$(LD) $(LDFLAGS) start.o superMarketTest4.o -o superMarketTest4.coff
	../bin/coff2noff superMarketTest4.coff superMarketTest4	
	
superMarketTest5.o: superMarketTest5.c
	$(CC) $(CFLAGS) -c superMarketTest5.c
superMarketTest5: superMarketTest5.o start.o
	$(LD) $(LDFLAGS) start.o superMarketTest5.o -o superMarketTest5.coff
	../bin/coff2noff superMarketTest5.coff superMarketTest5	
	
superMarketTest6.o: superMarketTest6.c
	$(CC) $(CFLAGS) -c superMarketTest6.c
superMarketTest6: superMarketTest6.o start.o
	$(LD) $(LDFLAGS) start.o superMarketTest6.o -o superMarketTest6.coff
	../bin/coff2noff superMarketTest6.coff superMarketTest6	
	
superMarketTest7.o: superMarketTest7.c
	$(CC) $(CFLAGS) -c superMarketTest7.c
superMarketTest7: superMarketTest7.o start.o
	$(LD) $(LDFLAGS) start.o superMarketTest7.o -o superMarketTest7.coff
	../bin/coff2noff superMarketTest7.coff superMarketTest7	
	
superMarketTest8.o: superMarketTest8.c
	$(CC) $(CFLAGS) -c superMarketTest8.c
superMarketTest8: superMarketTest8.o start.o
	$(LD) $(LDFLAGS) start.o superMarketTest8.o -o superMarketTest8.coff
	../bin/coff2noff superMarketTest8.coff superMarketTest8	

superMarketTest9.o: superMarketTest9.c
	$(CC) $(CFLAGS) -c superMarketTest9.c
superMarketTest9: superMarketTest9.o start.o
	$(LD) $(LDFLAGS) start.o superMarketTest9.o -o superMarketTest9.coff
	../bin/coff2noff superMarketTest9.coff superMarketTest9

superMarketTest10.o: superMarketTest10.c
	$(CC) $(CFLAGS) -c superMarketTest10.c
superMarketTest10: superMarketTest10.o start.o
	$(LD) $(LDFLAGS) start.o superMarketTest10.o -o superMarketTest10.coff
	../bin/coff2noff superMarketTest10.coff superMarketTest10	
	
networkLockTest.o: networkLockTest.c
	$(CC) $(CFLAGS) -c networkLockTest.c
networkLockTest: networkLockTest.o start.o
	$(LD) $(LDFLAGS) start.o networkLockTest.o -o networkLockTest.coff
	../bin/coff2noff networkLockTest.coff networkLockTest

networkWaitTest.o: networkWaitTest.c
	$(CC) $(CFLAGS) -c networkWaitTest.c
networkWaitTest: networkWaitTest.o start.o
	$(LD) $(LDFLAGS) start.o networkWaitTest.o -o networkWaitTest.coff
	../bin/coff2noff networkWaitTest.coff networkWaitTest	

networkSignalTest.o: networkSignalTest.c
	$(CC) $(CFLAGS) -c networkSignalTest.c
networkSignalTest: networkSignalTest.o start.o
	$(LD) $(LDFLAGS) start.o networkSignalTest.o -o networkSignalTest.coff
	../bin/coff2noff networkSignalTest.coff networkSignalTest	
	
networkBroadcastTest.o: networkBroadcastTest.c
	$(CC) $(CFLAGS) -c networkBroadcastTest.c
networkBroadcastTest: networkBroadcastTest.o start.o
	$(LD) $(LDFLAGS) start.o networkBroadcastTest.o -o networkBroadcastTest.coff
	../bin/coff2noff networkBroadcastTest.coff networkBroadcastTest	
	
	
clean:
	rm -f *.o *.coff
